<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <title>KindEditor JSP</title>
    <link rel="stylesheet" href="../../../static/plugins/kindeditor/themes/default/default.css"
          th:href="@{/plugins/kindeditor/themes/default/default.css}"/>
    <link rel="stylesheet" href="../../../static/plugins/kindeditor/plugins/code/prettify.css"
          th:href="@{/plugins/kindeditor/plugins/code/prettify.css}"/>
    <script charset="utf-8" src="../../../static/plugins/kindeditor/kindeditor-all.js"
            th:src="@{/plugins/kindeditor/kindeditor-all-min.js}"></script>
    <script charset="utf-8" src="../../../static/plugins/kindeditor/lang/zh-CN.js"
            th:src="@{/plugins/kindeditor/lang/zh-CN.js}"></script>
    <script charset="utf-8" src="../../../static/plugins/kindeditor/plugins/code/prettify.js"
            th:src="@{/plugins/kindeditor/plugins/code/prettify.js}"></script>
    <script charset="utf-8" src="../../../static/plugins/jquery/jquery.min.js"
            th:src="@{/plugins/jquery/jquery.min.js}"></script>
    <script th:inline="javascript">
        /*<![CDATA[*/
        var editor;

        $(document).ready(function () {
            // 在这里写你的代码...
            $('#showBtn').click(function () {
                debugger
                alert(11)
                // 设置HTML内容
                editor.html('HTML内容');
            });
        });


        KindEditor.ready(function (K) {
            var cssPath = '../../../static/plugins/kindeditor/plugins/code/prettify.css';
            /*[+ */
            cssPath = '/plugins/kindeditor/plugins/code/prettify.css';
            /* +]*/
            editor = K.create('textarea[name="content1"]', {
//                cssPath: '/plugins/kindeditor/plugins/code/prettify.css',
                cssPath: cssPath,
                uploadJson: '/upload_json',
                fileManagerJson: '/file_manager_json',
                allowFileManager: true,
                afterCreate: function () {
                    var self = this;
                    K.ctrl(document, 13, function () {
                        self.sync();
                        document.forms['example'].submit();
                    });
                    K.ctrl(self.edit.doc, 13, function () {
                        self.sync();
                        document.forms['example'].submit();
                    });
                }
            });
            prettyPrint();

            editor.html('[[${htmlData}]]');

            /*]]>*/
        });

    </script>
</head>
<body>
<form name="example" method="post" action="demo.html" th:action="@{/demo/kindeditor/save}">
    <textarea name="content1" cols="100" rows="8" style="width:700px;height:800px;visibility:hidden;"></textarea>
    <br/>
    <input type="submit" name="button" value="提交内容"/> (提交快捷键: Ctrl + Enter)

    <input type="button" name="showBtn" value="显示内容" id="showBtn"/>
</form>
</body>
</html>
